import { createContext } from "react";
import type { TaskProps, TaskMode, FlattenedTask } from "./types";
import type { Dayjs } from "dayjs";

export interface GanttContextProps {
  tasks: TaskProps[];
  setTasks: (tasks: TaskProps[]) => void;
  tasksStart: Dayjs;
  tasksEnd: Dayjs;
  taskMode: TaskMode;
  setTaskMode: (taskMode: TaskMode) => void;
  hideTaskTable: boolean;
  setHideTaskTable: (hideTaskTable: boolean) => void;
  containerWidth: number;
  containerHeight: number;
  ganttWidth: number;
  setGanttWidth: (ganttWidth: number) => void;
  ganttHeight: number;
  setGanttHeight: (ganttHeight: number) => void;

  flattenedTasks: FlattenedTask[];
  setFlattenedTasks: (tasks: FlattenedTask[]) => void;
  expandedTasks: Set<string>;
  setExpandedTasks: (expanded: Set<string>) => void;
  toggleExpand: (taskId: string) => void;

  // 垂直滚动同步状态
  scrollTop: number;
  setScrollTop: (scrollTop: number) => void;
  // 水平滚动同步状态
  scrollLeft: number;
  setScrollLeft: (scrollLeft: number) => void;
}

const GanttContext = createContext<GanttContextProps>({} as GanttContextProps);

export default GanttContext;
